
    ##############################################################################################
    # R code for the First 3 Columns (House) of Table 1 of Supplemental Material
    ##############################################################################################
    ### Note: This code requires the House Foreign Policy Votes Datasets: "FP_All_H79.csv", ..., "FP_All_H111.csv".

    library(MCMCpack)
 
    year.odd <- seq(from=1945, to=2009, by=2)
    T <- length(year.odd)
 
    # To report the share of the votes with zero discrimination parameters
    zero_discrim_percent <- rep(NA, T)
    zero_discrim_number <- rep(NA, T)
    total_vote_number <- rep(NA, T)

    ##############################################################################################   
    # Loop for 79 to 81th Houses.
    for(t in 79:81){
    Bills <- read.csv(paste("FP_All_H", t, ".csv", sep=""), header=T)
    bill.label <- colnames(Bills)[-c(1:5)]
    rownames(Bills) <- paste("A", Bills$ICPSR_ID, sep="")
    Sen  <- Bills[, -c(1:5)]
    N <- nrow(Sen)
    M <- ncol(Sen) 
    row.names(Sen) <- row.names(Bills)    
    # Use different constraints: # 79-81 = A8619;  F. Smith (R-OH) 
                                 # 82-86 = A3853;  H. Gross (R-IA)
                                 # 87-92 = A1611;  E. Celler (D-NY)
                                 # 93-111 = A13035; Charles Rangel (D-NY)
    MCMC <- MCMCirt1d(Sen, theta.constraints=list(A8619 = "-"),  
                      burnin=1000, mcmc=5000, thin=5, store.item=TRUE, store.ability=TRUE)   
    iter <- nrow(MCMC)
    gamma1.index <- N + seq(from=2, to=2*M, by=2) # gamma1 is the discrimination parameter
    gamma1.mc <- MCMC[seq(from=1, to=iter, length=iter) ,gamma1.index] 
    gamma1.CI  <- apply(gamma1.mc,  2, FUN=quantile, probs=c(0.025, 0.1, 0.5, 0.9, 0.975))
   
    ## Create and Save the list of Votes with zero discrimination parameters
    zero_list <- rep(NA, M)
    for(j in 1:M){ 
    if(0 < gamma1.CI[2, j] & 0 < gamma1.CI[4, j]) zero_list[j] <- 0 
    if(0 > gamma1.CI[2, j] & 0 > gamma1.CI[4, j]) zero_list[j] <- 0 
    if(0 < gamma1.CI[2, j] & 0 > gamma1.CI[4, j]) zero_list[j] <- 1 
    if(0 > gamma1.CI[2, j] & 0 < gamma1.CI[4, j]) zero_list[j] <- 1 
    }
    vote_list <- data.frame(zero_list, colnames(gamma1.mc))
    zero_list1 <- vote_list[zero_list==1,2]
    zero_discrim_percent[t-78] <- (sum(zero_list)/M)*100
    zero_discrim_number[t-78] <- sum(zero_list)
    total_vote_number[t-78] <- M
    } 

    ##############################################################################################   
    # Loop for 82 to 86th Houses.
    for(t in 82:86){
    Bills <- read.csv(paste("FP_All_H", t, ".csv", sep=""), header=T)
    bill.label <- colnames(Bills)[-c(1:5)]
    rownames(Bills) <- paste("A", Bills$ICPSR_ID, sep="")
    Sen  <- Bills[, -c(1:5)]
    N <- nrow(Sen)
    M <- ncol(Sen) 
    row.names(Sen) <- row.names(Bills)    
    # Use different constraints: # 79-81 = A8619;  F. Smith (R-OH) 
                                 # 82-86 = A3853;  H. Gross (R-IA)
                                 # 87-92 = A1611;  E. Celler (D-NY)
                                 # 93-111 = A13035; Charles Rangel (D-NY)
    MCMC <- MCMCirt1d(Sen, theta.constraints=list(A3853 = "-"),  
                      burnin=1000, mcmc=5000, thin=5, store.item=TRUE, store.ability=TRUE)   
    iter <- nrow(MCMC)
    gamma1.index <- N + seq(from=2, to=2*M, by=2) # gamma1 is the discrimination parameter
    gamma1.mc <- MCMC[seq(from=1, to=iter, length=iter) ,gamma1.index] 
    gamma1.CI  <- apply(gamma1.mc,  2, FUN=quantile, probs=c(0.025, 0.1, 0.5, 0.9, 0.975))
   
    ## Create and Save the list of Votes with zero discrimination parameters
    zero_list <- rep(NA, M)
    for(j in 1:M){ 
    if(0 < gamma1.CI[2, j] & 0 < gamma1.CI[4, j]) zero_list[j] <- 0 
    if(0 > gamma1.CI[2, j] & 0 > gamma1.CI[4, j]) zero_list[j] <- 0 
    if(0 < gamma1.CI[2, j] & 0 > gamma1.CI[4, j]) zero_list[j] <- 1 
    if(0 > gamma1.CI[2, j] & 0 < gamma1.CI[4, j]) zero_list[j] <- 1 
    }
    vote_list <- data.frame(zero_list, colnames(gamma1.mc))
    zero_list1 <- vote_list[zero_list==1,2]
    zero_discrim_percent[t-78] <- (sum(zero_list)/M)*100
    zero_discrim_number[t-78] <- sum(zero_list)
    total_vote_number[t-78] <- M
    } 

    ##############################################################################################   
    # Loop for 87 to 92th Houses.
    for(t in 87:92){
    Bills <- read.csv(paste("FP_All_H", t, ".csv", sep=""), header=T)
    bill.label <- colnames(Bills)[-c(1:5)]
    rownames(Bills) <- paste("A", Bills$ICPSR_ID, sep="")
    Sen  <- Bills[, -c(1:5)]
    N <- nrow(Sen)
    M <- ncol(Sen) 
    row.names(Sen) <- row.names(Bills)    
    # Use different constraints: # 79-81 = A8619;  F. Smith (R-OH) 
                                 # 82-86 = A3853;  H. Gross (R-IA)
                                 # 87-92 = A1611;  E. Celler (D-NY)
                                 # 93-111 = A13035; Charles Rangel (D-NY)
    MCMC <- MCMCirt1d(Sen, theta.constraints=list(A1611 = "-"),  
                      burnin=1000, mcmc=5000, thin=5, store.item=TRUE, store.ability=TRUE)   
    iter <- nrow(MCMC)
    gamma1.index <- N + seq(from=2, to=2*M, by=2) # gamma1 is the discrimination parameter
    gamma1.mc <- MCMC[seq(from=1, to=iter, length=iter) ,gamma1.index] 
    gamma1.CI  <- apply(gamma1.mc,  2, FUN=quantile, probs=c(0.025, 0.1, 0.5, 0.9, 0.975))
   
    ## Create and Save the list of Votes with zero discrimination parameters
    zero_list <- rep(NA, M)
    for(j in 1:M){ 
    if(0 < gamma1.CI[2, j] & 0 < gamma1.CI[4, j]) zero_list[j] <- 0 
    if(0 > gamma1.CI[2, j] & 0 > gamma1.CI[4, j]) zero_list[j] <- 0 
    if(0 < gamma1.CI[2, j] & 0 > gamma1.CI[4, j]) zero_list[j] <- 1 
    if(0 > gamma1.CI[2, j] & 0 < gamma1.CI[4, j]) zero_list[j] <- 1 
    }
    vote_list <- data.frame(zero_list, colnames(gamma1.mc))
    zero_list1 <- vote_list[zero_list==1,2]
    zero_discrim_percent[t-78] <- (sum(zero_list)/M)*100
    zero_discrim_number[t-78] <- sum(zero_list)
    total_vote_number[t-78] <- M
    } 

    ##############################################################################################   
    # Loop for 93 to 111th Houses.
    for(t in 93:111){
    Bills <- read.csv(paste("FP_All_H", t, ".csv", sep=""), header=T)
    bill.label <- colnames(Bills)[-c(1:5)]
    rownames(Bills) <- paste("A", Bills$ICPSR_ID, sep="")
    Sen  <- Bills[, -c(1:5)]
    N <- nrow(Sen)
    M <- ncol(Sen) 
    row.names(Sen) <- row.names(Bills)    
    # Use different constraints: # 79-81 = A8619;  F. Smith (R-OH) 
                                 # 82-86 = A3853;  H. Gross (R-IA)
                                 # 87-92 = A1611;  E. Celler (D-NY)
                                 # 93-111 = A13035; Charles Rangel (D-NY)
    MCMC <- MCMCirt1d(Sen, theta.constraints=list(A13035 = "-"),  
                      burnin=1000, mcmc=5000, thin=5, store.item=TRUE, store.ability=TRUE)   
    iter <- nrow(MCMC)
    gamma1.index <- N + seq(from=2, to=2*M, by=2) # gamma1 is the discrimination parameter
    gamma1.mc <- MCMC[seq(from=1, to=iter, length=iter) ,gamma1.index] 
    gamma1.CI  <- apply(gamma1.mc,  2, FUN=quantile, probs=c(0.025, 0.1, 0.5, 0.9, 0.975))
   
    ## Create and Save the list of Votes with zero discrimination parameters
    zero_list <- rep(NA, M)
    for(j in 1:M){ 
    if(0 < gamma1.CI[2, j] & 0 < gamma1.CI[4, j]) zero_list[j] <- 0 
    if(0 > gamma1.CI[2, j] & 0 > gamma1.CI[4, j]) zero_list[j] <- 0 
    if(0 < gamma1.CI[2, j] & 0 > gamma1.CI[4, j]) zero_list[j] <- 1 
    if(0 > gamma1.CI[2, j] & 0 < gamma1.CI[4, j]) zero_list[j] <- 1 
    }
    vote_list <- data.frame(zero_list, colnames(gamma1.mc))
    zero_list1 <- vote_list[zero_list==1,2]
    zero_discrim_percent[t-78] <- (sum(zero_list)/M)*100
    zero_discrim_number[t-78] <- sum(zero_list)
    total_vote_number[t-78] <- M
    } 

    # Report the number and percentage of votes with zero discrimination parameters
    Votes_discrim <- data.frame(total_vote_number, zero_discrim_number, zero_discrim_percent)    
    write.csv(Votes_discrim, "Supplemental_Table1_House.csv")
    

